{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import akshare as ak\n",
    "from pyecharts import *\n",
    "import datetime\n",
    "import sys\n",
    "from MyTT import *"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "显示juypter python解释器的位置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\mySpace\\\\mysoftware\\\\anaconda\\\\python.exe'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sys.executable"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "获取全市场股票"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>最新价</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "      <th>振幅</th>\n",
       "      <th>最高</th>\n",
       "      <th>...</th>\n",
       "      <th>量比</th>\n",
       "      <th>换手率</th>\n",
       "      <th>市盈率-动态</th>\n",
       "      <th>市净率</th>\n",
       "      <th>总市值</th>\n",
       "      <th>流通市值</th>\n",
       "      <th>涨速</th>\n",
       "      <th>5分钟涨跌</th>\n",
       "      <th>60日涨跌幅</th>\n",
       "      <th>年初至今涨跌幅</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>300049</td>\n",
       "      <td>福瑞股份</td>\n",
       "      <td>23.16</td>\n",
       "      <td>20.00</td>\n",
       "      <td>3.86</td>\n",
       "      <td>53240.0</td>\n",
       "      <td>1.233041e+08</td>\n",
       "      <td>0.00</td>\n",
       "      <td>23.16</td>\n",
       "      <td>...</td>\n",
       "      <td>2.42</td>\n",
       "      <td>2.31</td>\n",
       "      <td>75.20</td>\n",
       "      <td>3.94</td>\n",
       "      <td>6.092310e+09</td>\n",
       "      <td>5.341966e+09</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>15.57</td>\n",
       "      <td>57.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>688555</td>\n",
       "      <td>*ST泽达</td>\n",
       "      <td>4.25</td>\n",
       "      <td>16.12</td>\n",
       "      <td>0.59</td>\n",
       "      <td>50670.0</td>\n",
       "      <td>2.037530e+07</td>\n",
       "      <td>18.85</td>\n",
       "      <td>4.34</td>\n",
       "      <td>...</td>\n",
       "      <td>5.10</td>\n",
       "      <td>12.11</td>\n",
       "      <td>-5.39</td>\n",
       "      <td>0.44</td>\n",
       "      <td>3.532175e+08</td>\n",
       "      <td>1.778285e+08</td>\n",
       "      <td>0.24</td>\n",
       "      <td>0.47</td>\n",
       "      <td>-67.05</td>\n",
       "      <td>-88.29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>301248</td>\n",
       "      <td>杰创智能</td>\n",
       "      <td>28.74</td>\n",
       "      <td>13.24</td>\n",
       "      <td>3.36</td>\n",
       "      <td>43848.0</td>\n",
       "      <td>1.233410e+08</td>\n",
       "      <td>17.02</td>\n",
       "      <td>30.33</td>\n",
       "      <td>...</td>\n",
       "      <td>16.23</td>\n",
       "      <td>17.94</td>\n",
       "      <td>45.50</td>\n",
       "      <td>1.87</td>\n",
       "      <td>2.944988e+09</td>\n",
       "      <td>7.024355e+08</td>\n",
       "      <td>0.14</td>\n",
       "      <td>0.14</td>\n",
       "      <td>2.94</td>\n",
       "      <td>-26.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>688086</td>\n",
       "      <td>*ST紫晶</td>\n",
       "      <td>2.79</td>\n",
       "      <td>12.50</td>\n",
       "      <td>0.31</td>\n",
       "      <td>71918.0</td>\n",
       "      <td>1.921395e+07</td>\n",
       "      <td>14.11</td>\n",
       "      <td>2.80</td>\n",
       "      <td>...</td>\n",
       "      <td>4.44</td>\n",
       "      <td>5.41</td>\n",
       "      <td>-2.13</td>\n",
       "      <td>0.39</td>\n",
       "      <td>5.311644e+08</td>\n",
       "      <td>3.709909e+08</td>\n",
       "      <td>0.72</td>\n",
       "      <td>1.09</td>\n",
       "      <td>-62.70</td>\n",
       "      <td>-87.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>300812</td>\n",
       "      <td>易天股份</td>\n",
       "      <td>23.65</td>\n",
       "      <td>10.26</td>\n",
       "      <td>2.20</td>\n",
       "      <td>180089.0</td>\n",
       "      <td>4.161472e+08</td>\n",
       "      <td>13.10</td>\n",
       "      <td>24.16</td>\n",
       "      <td>...</td>\n",
       "      <td>3.68</td>\n",
       "      <td>30.51</td>\n",
       "      <td>61.35</td>\n",
       "      <td>3.86</td>\n",
       "      <td>3.306767e+09</td>\n",
       "      <td>1.395821e+09</td>\n",
       "      <td>-0.71</td>\n",
       "      <td>-0.50</td>\n",
       "      <td>42.99</td>\n",
       "      <td>9.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5239</th>\n",
       "      <td>5240</td>\n",
       "      <td>300436</td>\n",
       "      <td>广生堂</td>\n",
       "      <td>41.11</td>\n",
       "      <td>-11.59</td>\n",
       "      <td>-5.39</td>\n",
       "      <td>120995.0</td>\n",
       "      <td>5.234826e+08</td>\n",
       "      <td>10.88</td>\n",
       "      <td>46.07</td>\n",
       "      <td>...</td>\n",
       "      <td>2.20</td>\n",
       "      <td>9.08</td>\n",
       "      <td>-68.69</td>\n",
       "      <td>6.64</td>\n",
       "      <td>6.547466e+09</td>\n",
       "      <td>5.478144e+09</td>\n",
       "      <td>-0.02</td>\n",
       "      <td>-0.75</td>\n",
       "      <td>21.34</td>\n",
       "      <td>-14.41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5240</th>\n",
       "      <td>5241</td>\n",
       "      <td>301075</td>\n",
       "      <td>多瑞医药</td>\n",
       "      <td>41.70</td>\n",
       "      <td>-11.69</td>\n",
       "      <td>-5.52</td>\n",
       "      <td>44146.0</td>\n",
       "      <td>1.889306e+08</td>\n",
       "      <td>8.62</td>\n",
       "      <td>45.27</td>\n",
       "      <td>...</td>\n",
       "      <td>1.29</td>\n",
       "      <td>16.10</td>\n",
       "      <td>111.26</td>\n",
       "      <td>4.42</td>\n",
       "      <td>3.336000e+09</td>\n",
       "      <td>1.143569e+09</td>\n",
       "      <td>-0.45</td>\n",
       "      <td>-0.60</td>\n",
       "      <td>88.94</td>\n",
       "      <td>8.91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5241</th>\n",
       "      <td>5242</td>\n",
       "      <td>836807</td>\n",
       "      <td>N奔朗</td>\n",
       "      <td>5.90</td>\n",
       "      <td>-15.71</td>\n",
       "      <td>-1.10</td>\n",
       "      <td>43215.0</td>\n",
       "      <td>2.569085e+07</td>\n",
       "      <td>3.71</td>\n",
       "      <td>6.10</td>\n",
       "      <td>...</td>\n",
       "      <td>1875.82</td>\n",
       "      <td>5.54</td>\n",
       "      <td>14.05</td>\n",
       "      <td>1.14</td>\n",
       "      <td>1.073092e+09</td>\n",
       "      <td>4.602136e+08</td>\n",
       "      <td>0.17</td>\n",
       "      <td>0.17</td>\n",
       "      <td>-32.95</td>\n",
       "      <td>-60.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5242</th>\n",
       "      <td>5243</td>\n",
       "      <td>300212</td>\n",
       "      <td>易华录</td>\n",
       "      <td>20.50</td>\n",
       "      <td>-15.78</td>\n",
       "      <td>-3.84</td>\n",
       "      <td>462652.0</td>\n",
       "      <td>1.000611e+09</td>\n",
       "      <td>20.46</td>\n",
       "      <td>25.18</td>\n",
       "      <td>...</td>\n",
       "      <td>4.04</td>\n",
       "      <td>7.41</td>\n",
       "      <td>-800.11</td>\n",
       "      <td>3.50</td>\n",
       "      <td>1.364919e+10</td>\n",
       "      <td>1.279975e+10</td>\n",
       "      <td>-0.44</td>\n",
       "      <td>-1.35</td>\n",
       "      <td>53.56</td>\n",
       "      <td>-42.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5243</th>\n",
       "      <td>5244</td>\n",
       "      <td>300089</td>\n",
       "      <td>*ST文化</td>\n",
       "      <td>2.18</td>\n",
       "      <td>-20.15</td>\n",
       "      <td>-0.55</td>\n",
       "      <td>346749.0</td>\n",
       "      <td>7.727774e+07</td>\n",
       "      <td>10.62</td>\n",
       "      <td>2.47</td>\n",
       "      <td>...</td>\n",
       "      <td>5.99</td>\n",
       "      <td>8.55</td>\n",
       "      <td>-13.00</td>\n",
       "      <td>-3.03</td>\n",
       "      <td>1.048704e+09</td>\n",
       "      <td>8.842667e+08</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-47.22</td>\n",
       "      <td>-55.96</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5244 rows × 23 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        序号      代码     名称    最新价    涨跌幅   涨跌额       成交量           成交额     振幅  \\\n",
       "0        1  300049   福瑞股份  23.16  20.00  3.86   53240.0  1.233041e+08   0.00   \n",
       "1        2  688555  *ST泽达   4.25  16.12  0.59   50670.0  2.037530e+07  18.85   \n",
       "2        3  301248   杰创智能  28.74  13.24  3.36   43848.0  1.233410e+08  17.02   \n",
       "3        4  688086  *ST紫晶   2.79  12.50  0.31   71918.0  1.921395e+07  14.11   \n",
       "4        5  300812   易天股份  23.65  10.26  2.20  180089.0  4.161472e+08  13.10   \n",
       "...    ...     ...    ...    ...    ...   ...       ...           ...    ...   \n",
       "5239  5240  300436    广生堂  41.11 -11.59 -5.39  120995.0  5.234826e+08  10.88   \n",
       "5240  5241  301075   多瑞医药  41.70 -11.69 -5.52   44146.0  1.889306e+08   8.62   \n",
       "5241  5242  836807    N奔朗   5.90 -15.71 -1.10   43215.0  2.569085e+07   3.71   \n",
       "5242  5243  300212    易华录  20.50 -15.78 -3.84  462652.0  1.000611e+09  20.46   \n",
       "5243  5244  300089  *ST文化   2.18 -20.15 -0.55  346749.0  7.727774e+07  10.62   \n",
       "\n",
       "         最高  ...       量比    换手率  市盈率-动态   市净率           总市值          流通市值  \\\n",
       "0     23.16  ...     2.42   2.31   75.20  3.94  6.092310e+09  5.341966e+09   \n",
       "1      4.34  ...     5.10  12.11   -5.39  0.44  3.532175e+08  1.778285e+08   \n",
       "2     30.33  ...    16.23  17.94   45.50  1.87  2.944988e+09  7.024355e+08   \n",
       "3      2.80  ...     4.44   5.41   -2.13  0.39  5.311644e+08  3.709909e+08   \n",
       "4     24.16  ...     3.68  30.51   61.35  3.86  3.306767e+09  1.395821e+09   \n",
       "...     ...  ...      ...    ...     ...   ...           ...           ...   \n",
       "5239  46.07  ...     2.20   9.08  -68.69  6.64  6.547466e+09  5.478144e+09   \n",
       "5240  45.27  ...     1.29  16.10  111.26  4.42  3.336000e+09  1.143569e+09   \n",
       "5241   6.10  ...  1875.82   5.54   14.05  1.14  1.073092e+09  4.602136e+08   \n",
       "5242  25.18  ...     4.04   7.41 -800.11  3.50  1.364919e+10  1.279975e+10   \n",
       "5243   2.47  ...     5.99   8.55  -13.00 -3.03  1.048704e+09  8.842667e+08   \n",
       "\n",
       "        涨速  5分钟涨跌  60日涨跌幅  年初至今涨跌幅  \n",
       "0     0.00   0.00   15.57    57.55  \n",
       "1     0.24   0.47  -67.05   -88.29  \n",
       "2     0.14   0.14    2.94   -26.06  \n",
       "3     0.72   1.09  -62.70   -87.32  \n",
       "4    -0.71  -0.50   42.99     9.90  \n",
       "...    ...    ...     ...      ...  \n",
       "5239 -0.02  -0.75   21.34   -14.41  \n",
       "5240 -0.45  -0.60   88.94     8.91  \n",
       "5241  0.17   0.17  -32.95   -60.27  \n",
       "5242 -0.44  -1.35   53.56   -42.01  \n",
       "5243  0.00   0.00  -47.22   -55.96  \n",
       "\n",
       "[5244 rows x 23 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_zh_a_spot_em_df = ak.stock_zh_a_spot_em()\n",
    "stock_zh_a_spot_em_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "剔除掉科创板、创业板、新股、st股"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>最新价</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "      <th>振幅</th>\n",
       "      <th>最高</th>\n",
       "      <th>...</th>\n",
       "      <th>量比</th>\n",
       "      <th>换手率</th>\n",
       "      <th>市盈率-动态</th>\n",
       "      <th>市净率</th>\n",
       "      <th>总市值</th>\n",
       "      <th>流通市值</th>\n",
       "      <th>涨速</th>\n",
       "      <th>5分钟涨跌</th>\n",
       "      <th>60日涨跌幅</th>\n",
       "      <th>年初至今涨跌幅</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>002031</td>\n",
       "      <td>巨轮智能</td>\n",
       "      <td>3.16</td>\n",
       "      <td>10.10</td>\n",
       "      <td>0.29</td>\n",
       "      <td>2794342.0</td>\n",
       "      <td>8.565556e+08</td>\n",
       "      <td>12.20</td>\n",
       "      <td>3.16</td>\n",
       "      <td>...</td>\n",
       "      <td>3.93</td>\n",
       "      <td>14.45</td>\n",
       "      <td>721.59</td>\n",
       "      <td>2.86</td>\n",
       "      <td>6.950090e+09</td>\n",
       "      <td>6.110875e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-5.95</td>\n",
       "      <td>49.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>002999</td>\n",
       "      <td>天禾股份</td>\n",
       "      <td>10.08</td>\n",
       "      <td>10.04</td>\n",
       "      <td>0.92</td>\n",
       "      <td>410272.0</td>\n",
       "      <td>4.018137e+08</td>\n",
       "      <td>11.68</td>\n",
       "      <td>10.08</td>\n",
       "      <td>...</td>\n",
       "      <td>5.77</td>\n",
       "      <td>18.84</td>\n",
       "      <td>29.32</td>\n",
       "      <td>3.07</td>\n",
       "      <td>3.503727e+09</td>\n",
       "      <td>2.195136e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>46.94</td>\n",
       "      <td>48.89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>000698</td>\n",
       "      <td>沈阳化工</td>\n",
       "      <td>5.27</td>\n",
       "      <td>10.02</td>\n",
       "      <td>0.48</td>\n",
       "      <td>470033.0</td>\n",
       "      <td>2.453166e+08</td>\n",
       "      <td>10.23</td>\n",
       "      <td>5.27</td>\n",
       "      <td>...</td>\n",
       "      <td>3.52</td>\n",
       "      <td>5.98</td>\n",
       "      <td>-13.32</td>\n",
       "      <td>1.11</td>\n",
       "      <td>4.318841e+09</td>\n",
       "      <td>4.140694e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>17.90</td>\n",
       "      <td>-10.22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>000404</td>\n",
       "      <td>长虹华意</td>\n",
       "      <td>5.93</td>\n",
       "      <td>10.02</td>\n",
       "      <td>0.54</td>\n",
       "      <td>829143.0</td>\n",
       "      <td>4.771573e+08</td>\n",
       "      <td>10.95</td>\n",
       "      <td>5.93</td>\n",
       "      <td>...</td>\n",
       "      <td>14.69</td>\n",
       "      <td>11.92</td>\n",
       "      <td>21.37</td>\n",
       "      <td>1.19</td>\n",
       "      <td>4.127256e+09</td>\n",
       "      <td>4.125897e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>13.17</td>\n",
       "      <td>30.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>600847</td>\n",
       "      <td>万里股份</td>\n",
       "      <td>15.40</td>\n",
       "      <td>10.00</td>\n",
       "      <td>1.40</td>\n",
       "      <td>62639.0</td>\n",
       "      <td>9.382200e+07</td>\n",
       "      <td>11.00</td>\n",
       "      <td>15.40</td>\n",
       "      <td>...</td>\n",
       "      <td>3.60</td>\n",
       "      <td>4.09</td>\n",
       "      <td>-69.32</td>\n",
       "      <td>3.41</td>\n",
       "      <td>2.360626e+09</td>\n",
       "      <td>2.360626e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-17.65</td>\n",
       "      <td>-9.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5234</th>\n",
       "      <td>5235</td>\n",
       "      <td>000736</td>\n",
       "      <td>中交地产</td>\n",
       "      <td>20.26</td>\n",
       "      <td>-10.00</td>\n",
       "      <td>-2.25</td>\n",
       "      <td>183943.0</td>\n",
       "      <td>3.731694e+08</td>\n",
       "      <td>1.95</td>\n",
       "      <td>20.70</td>\n",
       "      <td>...</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.65</td>\n",
       "      <td>-60.67</td>\n",
       "      <td>4.61</td>\n",
       "      <td>1.408949e+10</td>\n",
       "      <td>1.408949e+10</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>28.39</td>\n",
       "      <td>221.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5235</th>\n",
       "      <td>5236</td>\n",
       "      <td>002898</td>\n",
       "      <td>赛隆药业</td>\n",
       "      <td>12.96</td>\n",
       "      <td>-10.00</td>\n",
       "      <td>-1.44</td>\n",
       "      <td>34936.0</td>\n",
       "      <td>4.530129e+07</td>\n",
       "      <td>1.81</td>\n",
       "      <td>13.22</td>\n",
       "      <td>...</td>\n",
       "      <td>0.49</td>\n",
       "      <td>3.46</td>\n",
       "      <td>1008.06</td>\n",
       "      <td>4.03</td>\n",
       "      <td>2.280960e+09</td>\n",
       "      <td>1.308766e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>18.57</td>\n",
       "      <td>24.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5236</th>\n",
       "      <td>5237</td>\n",
       "      <td>600602</td>\n",
       "      <td>云赛智联</td>\n",
       "      <td>8.36</td>\n",
       "      <td>-10.01</td>\n",
       "      <td>-0.93</td>\n",
       "      <td>714775.0</td>\n",
       "      <td>6.206516e+08</td>\n",
       "      <td>12.16</td>\n",
       "      <td>9.49</td>\n",
       "      <td>...</td>\n",
       "      <td>2.43</td>\n",
       "      <td>6.65</td>\n",
       "      <td>56.35</td>\n",
       "      <td>2.53</td>\n",
       "      <td>1.143375e+10</td>\n",
       "      <td>8.981173e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.24</td>\n",
       "      <td>39.57</td>\n",
       "      <td>29.81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5237</th>\n",
       "      <td>5238</td>\n",
       "      <td>000032</td>\n",
       "      <td>深桑达Ａ</td>\n",
       "      <td>22.65</td>\n",
       "      <td>-10.01</td>\n",
       "      <td>-2.52</td>\n",
       "      <td>446485.0</td>\n",
       "      <td>1.049805e+09</td>\n",
       "      <td>14.14</td>\n",
       "      <td>26.21</td>\n",
       "      <td>...</td>\n",
       "      <td>2.92</td>\n",
       "      <td>6.92</td>\n",
       "      <td>-35.35</td>\n",
       "      <td>4.83</td>\n",
       "      <td>2.577478e+10</td>\n",
       "      <td>1.460390e+10</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.04</td>\n",
       "      <td>71.33</td>\n",
       "      <td>9.74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5238</th>\n",
       "      <td>5239</td>\n",
       "      <td>002591</td>\n",
       "      <td>恒大高新</td>\n",
       "      <td>7.61</td>\n",
       "      <td>-10.05</td>\n",
       "      <td>-0.85</td>\n",
       "      <td>124099.0</td>\n",
       "      <td>9.446975e+07</td>\n",
       "      <td>0.95</td>\n",
       "      <td>7.69</td>\n",
       "      <td>...</td>\n",
       "      <td>0.79</td>\n",
       "      <td>5.73</td>\n",
       "      <td>-435.90</td>\n",
       "      <td>2.96</td>\n",
       "      <td>2.284518e+09</td>\n",
       "      <td>1.648935e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>3.26</td>\n",
       "      <td>33.51</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3345 rows × 23 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        序号      代码    名称    最新价    涨跌幅   涨跌额        成交量           成交额     振幅  \\\n",
       "5        6  002031  巨轮智能   3.16  10.10  0.29  2794342.0  8.565556e+08  12.20   \n",
       "6        7  002999  天禾股份  10.08  10.04  0.92   410272.0  4.018137e+08  11.68   \n",
       "7        8  000698  沈阳化工   5.27  10.02  0.48   470033.0  2.453166e+08  10.23   \n",
       "8        9  000404  长虹华意   5.93  10.02  0.54   829143.0  4.771573e+08  10.95   \n",
       "9       10  600847  万里股份  15.40  10.00  1.40    62639.0  9.382200e+07  11.00   \n",
       "...    ...     ...   ...    ...    ...   ...        ...           ...    ...   \n",
       "5234  5235  000736  中交地产  20.26 -10.00 -2.25   183943.0  3.731694e+08   1.95   \n",
       "5235  5236  002898  赛隆药业  12.96 -10.00 -1.44    34936.0  4.530129e+07   1.81   \n",
       "5236  5237  600602  云赛智联   8.36 -10.01 -0.93   714775.0  6.206516e+08  12.16   \n",
       "5237  5238  000032  深桑达Ａ  22.65 -10.01 -2.52   446485.0  1.049805e+09  14.14   \n",
       "5238  5239  002591  恒大高新   7.61 -10.05 -0.85   124099.0  9.446975e+07   0.95   \n",
       "\n",
       "         最高  ...     量比    换手率   市盈率-动态   市净率           总市值          流通市值  \\\n",
       "5      3.16  ...   3.93  14.45   721.59  2.86  6.950090e+09  6.110875e+09   \n",
       "6     10.08  ...   5.77  18.84    29.32  3.07  3.503727e+09  2.195136e+09   \n",
       "7      5.27  ...   3.52   5.98   -13.32  1.11  4.318841e+09  4.140694e+09   \n",
       "8      5.93  ...  14.69  11.92    21.37  1.19  4.127256e+09  4.125897e+09   \n",
       "9     15.40  ...   3.60   4.09   -69.32  3.41  2.360626e+09  2.360626e+09   \n",
       "...     ...  ...    ...    ...      ...   ...           ...           ...   \n",
       "5234  20.70  ...   0.63   2.65   -60.67  4.61  1.408949e+10  1.408949e+10   \n",
       "5235  13.22  ...   0.49   3.46  1008.06  4.03  2.280960e+09  1.308766e+09   \n",
       "5236   9.49  ...   2.43   6.65    56.35  2.53  1.143375e+10  8.981173e+09   \n",
       "5237  26.21  ...   2.92   6.92   -35.35  4.83  2.577478e+10  1.460390e+10   \n",
       "5238   7.69  ...   0.79   5.73  -435.90  2.96  2.284518e+09  1.648935e+09   \n",
       "\n",
       "       涨速  5分钟涨跌  60日涨跌幅  年初至今涨跌幅  \n",
       "5     0.0   0.00   -5.95    49.06  \n",
       "6     0.0   0.00   46.94    48.89  \n",
       "7     0.0   0.00   17.90   -10.22  \n",
       "8     0.0   0.00   13.17    30.62  \n",
       "9     0.0   0.00  -17.65    -9.78  \n",
       "...   ...    ...     ...      ...  \n",
       "5234  0.0   0.00   28.39   221.08  \n",
       "5235  0.0   0.00   18.57    24.02  \n",
       "5236  0.0  -0.24   39.57    29.81  \n",
       "5237  0.0  -0.04   71.33     9.74  \n",
       "5238  0.0   0.00    3.26    33.51  \n",
       "\n",
       "[3345 rows x 23 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "washed_stocks = stock_zh_a_spot_em_df[(stock_zh_a_spot_em_df['代码'].str.startswith('00') | stock_zh_a_spot_em_df['代码'].str.startswith('60')) & (~stock_zh_a_spot_em_df['名称'].str.startswith('N') & ~stock_zh_a_spot_em_df['名称'].str.contains('st'))]\n",
    "washed_stocks"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "筛选涨跌幅大于9的股票"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>最新价</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>涨跌额</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "      <th>振幅</th>\n",
       "      <th>最高</th>\n",
       "      <th>...</th>\n",
       "      <th>量比</th>\n",
       "      <th>换手率</th>\n",
       "      <th>市盈率-动态</th>\n",
       "      <th>市净率</th>\n",
       "      <th>总市值</th>\n",
       "      <th>流通市值</th>\n",
       "      <th>涨速</th>\n",
       "      <th>5分钟涨跌</th>\n",
       "      <th>60日涨跌幅</th>\n",
       "      <th>年初至今涨跌幅</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>002031</td>\n",
       "      <td>巨轮智能</td>\n",
       "      <td>3.16</td>\n",
       "      <td>10.10</td>\n",
       "      <td>0.29</td>\n",
       "      <td>2794342.0</td>\n",
       "      <td>8.565556e+08</td>\n",
       "      <td>12.20</td>\n",
       "      <td>3.16</td>\n",
       "      <td>...</td>\n",
       "      <td>3.93</td>\n",
       "      <td>14.45</td>\n",
       "      <td>721.59</td>\n",
       "      <td>2.86</td>\n",
       "      <td>6.950090e+09</td>\n",
       "      <td>6.110875e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-5.95</td>\n",
       "      <td>49.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>002999</td>\n",
       "      <td>天禾股份</td>\n",
       "      <td>10.08</td>\n",
       "      <td>10.04</td>\n",
       "      <td>0.92</td>\n",
       "      <td>410272.0</td>\n",
       "      <td>4.018137e+08</td>\n",
       "      <td>11.68</td>\n",
       "      <td>10.08</td>\n",
       "      <td>...</td>\n",
       "      <td>5.77</td>\n",
       "      <td>18.84</td>\n",
       "      <td>29.32</td>\n",
       "      <td>3.07</td>\n",
       "      <td>3.503727e+09</td>\n",
       "      <td>2.195136e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>46.94</td>\n",
       "      <td>48.89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>000698</td>\n",
       "      <td>沈阳化工</td>\n",
       "      <td>5.27</td>\n",
       "      <td>10.02</td>\n",
       "      <td>0.48</td>\n",
       "      <td>470033.0</td>\n",
       "      <td>2.453166e+08</td>\n",
       "      <td>10.23</td>\n",
       "      <td>5.27</td>\n",
       "      <td>...</td>\n",
       "      <td>3.52</td>\n",
       "      <td>5.98</td>\n",
       "      <td>-13.32</td>\n",
       "      <td>1.11</td>\n",
       "      <td>4.318841e+09</td>\n",
       "      <td>4.140694e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>17.90</td>\n",
       "      <td>-10.22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>000404</td>\n",
       "      <td>长虹华意</td>\n",
       "      <td>5.93</td>\n",
       "      <td>10.02</td>\n",
       "      <td>0.54</td>\n",
       "      <td>829143.0</td>\n",
       "      <td>4.771573e+08</td>\n",
       "      <td>10.95</td>\n",
       "      <td>5.93</td>\n",
       "      <td>...</td>\n",
       "      <td>14.69</td>\n",
       "      <td>11.92</td>\n",
       "      <td>21.37</td>\n",
       "      <td>1.19</td>\n",
       "      <td>4.127256e+09</td>\n",
       "      <td>4.125897e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>13.17</td>\n",
       "      <td>30.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>600847</td>\n",
       "      <td>万里股份</td>\n",
       "      <td>15.40</td>\n",
       "      <td>10.00</td>\n",
       "      <td>1.40</td>\n",
       "      <td>62639.0</td>\n",
       "      <td>9.382200e+07</td>\n",
       "      <td>11.00</td>\n",
       "      <td>15.40</td>\n",
       "      <td>...</td>\n",
       "      <td>3.60</td>\n",
       "      <td>4.09</td>\n",
       "      <td>-69.32</td>\n",
       "      <td>3.41</td>\n",
       "      <td>2.360626e+09</td>\n",
       "      <td>2.360626e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-17.65</td>\n",
       "      <td>-9.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>11</td>\n",
       "      <td>003026</td>\n",
       "      <td>中晶科技</td>\n",
       "      <td>55.99</td>\n",
       "      <td>10.00</td>\n",
       "      <td>5.09</td>\n",
       "      <td>109117.0</td>\n",
       "      <td>5.994179e+08</td>\n",
       "      <td>11.51</td>\n",
       "      <td>55.99</td>\n",
       "      <td>...</td>\n",
       "      <td>5.41</td>\n",
       "      <td>19.75</td>\n",
       "      <td>174.10</td>\n",
       "      <td>7.58</td>\n",
       "      <td>5.655991e+09</td>\n",
       "      <td>3.093854e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>32.05</td>\n",
       "      <td>-23.77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>12</td>\n",
       "      <td>002327</td>\n",
       "      <td>富安娜</td>\n",
       "      <td>8.14</td>\n",
       "      <td>10.00</td>\n",
       "      <td>0.74</td>\n",
       "      <td>316296.0</td>\n",
       "      <td>2.505854e+08</td>\n",
       "      <td>11.08</td>\n",
       "      <td>8.14</td>\n",
       "      <td>...</td>\n",
       "      <td>14.82</td>\n",
       "      <td>6.53</td>\n",
       "      <td>15.46</td>\n",
       "      <td>1.90</td>\n",
       "      <td>6.751796e+09</td>\n",
       "      <td>3.942938e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>20.41</td>\n",
       "      <td>2.52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>13</td>\n",
       "      <td>002186</td>\n",
       "      <td>全 聚 德</td>\n",
       "      <td>14.74</td>\n",
       "      <td>10.00</td>\n",
       "      <td>1.34</td>\n",
       "      <td>258409.0</td>\n",
       "      <td>3.765017e+08</td>\n",
       "      <td>5.30</td>\n",
       "      <td>14.74</td>\n",
       "      <td>...</td>\n",
       "      <td>4.83</td>\n",
       "      <td>8.39</td>\n",
       "      <td>-19.47</td>\n",
       "      <td>5.37</td>\n",
       "      <td>4.546759e+09</td>\n",
       "      <td>4.540712e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>65.62</td>\n",
       "      <td>52.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>14</td>\n",
       "      <td>002162</td>\n",
       "      <td>悦心健康</td>\n",
       "      <td>5.39</td>\n",
       "      <td>10.00</td>\n",
       "      <td>0.49</td>\n",
       "      <td>965012.0</td>\n",
       "      <td>4.961033e+08</td>\n",
       "      <td>8.98</td>\n",
       "      <td>5.39</td>\n",
       "      <td>...</td>\n",
       "      <td>8.17</td>\n",
       "      <td>11.31</td>\n",
       "      <td>-43.77</td>\n",
       "      <td>4.16</td>\n",
       "      <td>4.993835e+09</td>\n",
       "      <td>4.600270e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>28.03</td>\n",
       "      <td>12.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>15</td>\n",
       "      <td>001209</td>\n",
       "      <td>洪兴股份</td>\n",
       "      <td>17.71</td>\n",
       "      <td>10.00</td>\n",
       "      <td>1.61</td>\n",
       "      <td>118622.0</td>\n",
       "      <td>2.069527e+08</td>\n",
       "      <td>10.25</td>\n",
       "      <td>17.71</td>\n",
       "      <td>...</td>\n",
       "      <td>4.59</td>\n",
       "      <td>31.92</td>\n",
       "      <td>533.97</td>\n",
       "      <td>1.86</td>\n",
       "      <td>2.329267e+09</td>\n",
       "      <td>6.582387e+08</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>13.02</td>\n",
       "      <td>-9.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>16</td>\n",
       "      <td>001217</td>\n",
       "      <td>华尔泰</td>\n",
       "      <td>14.09</td>\n",
       "      <td>9.99</td>\n",
       "      <td>1.28</td>\n",
       "      <td>64808.0</td>\n",
       "      <td>8.922227e+07</td>\n",
       "      <td>9.37</td>\n",
       "      <td>14.09</td>\n",
       "      <td>...</td>\n",
       "      <td>5.02</td>\n",
       "      <td>4.53</td>\n",
       "      <td>19.41</td>\n",
       "      <td>2.30</td>\n",
       "      <td>4.676048e+09</td>\n",
       "      <td>2.017742e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.14</td>\n",
       "      <td>-26.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>17</td>\n",
       "      <td>603912</td>\n",
       "      <td>佳力图</td>\n",
       "      <td>12.44</td>\n",
       "      <td>9.99</td>\n",
       "      <td>1.13</td>\n",
       "      <td>279163.0</td>\n",
       "      <td>3.467028e+08</td>\n",
       "      <td>3.80</td>\n",
       "      <td>12.44</td>\n",
       "      <td>...</td>\n",
       "      <td>13.39</td>\n",
       "      <td>9.19</td>\n",
       "      <td>135.41</td>\n",
       "      <td>4.02</td>\n",
       "      <td>3.778563e+09</td>\n",
       "      <td>3.778563e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>21.25</td>\n",
       "      <td>20.66</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>18</td>\n",
       "      <td>002095</td>\n",
       "      <td>生 意 宝</td>\n",
       "      <td>21.69</td>\n",
       "      <td>9.99</td>\n",
       "      <td>1.97</td>\n",
       "      <td>45486.0</td>\n",
       "      <td>9.865879e+07</td>\n",
       "      <td>0.00</td>\n",
       "      <td>21.69</td>\n",
       "      <td>...</td>\n",
       "      <td>1.00</td>\n",
       "      <td>1.81</td>\n",
       "      <td>238.70</td>\n",
       "      <td>5.93</td>\n",
       "      <td>5.481497e+09</td>\n",
       "      <td>5.459556e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>77.64</td>\n",
       "      <td>31.61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>19</td>\n",
       "      <td>002231</td>\n",
       "      <td>奥维通信</td>\n",
       "      <td>7.94</td>\n",
       "      <td>9.97</td>\n",
       "      <td>0.72</td>\n",
       "      <td>178932.0</td>\n",
       "      <td>1.381095e+08</td>\n",
       "      <td>10.53</td>\n",
       "      <td>7.94</td>\n",
       "      <td>...</td>\n",
       "      <td>5.61</td>\n",
       "      <td>6.07</td>\n",
       "      <td>-466.62</td>\n",
       "      <td>6.91</td>\n",
       "      <td>2.753989e+09</td>\n",
       "      <td>2.340849e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.75</td>\n",
       "      <td>31.67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>20</td>\n",
       "      <td>002888</td>\n",
       "      <td>惠威科技</td>\n",
       "      <td>12.69</td>\n",
       "      <td>9.97</td>\n",
       "      <td>1.15</td>\n",
       "      <td>26920.0</td>\n",
       "      <td>3.344229e+07</td>\n",
       "      <td>9.88</td>\n",
       "      <td>12.69</td>\n",
       "      <td>...</td>\n",
       "      <td>2.48</td>\n",
       "      <td>3.58</td>\n",
       "      <td>725.76</td>\n",
       "      <td>4.58</td>\n",
       "      <td>1.898572e+09</td>\n",
       "      <td>9.541855e+08</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.49</td>\n",
       "      <td>-3.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>21</td>\n",
       "      <td>002235</td>\n",
       "      <td>安妮股份</td>\n",
       "      <td>5.43</td>\n",
       "      <td>9.92</td>\n",
       "      <td>0.49</td>\n",
       "      <td>578241.0</td>\n",
       "      <td>3.076781e+08</td>\n",
       "      <td>5.67</td>\n",
       "      <td>5.43</td>\n",
       "      <td>...</td>\n",
       "      <td>4.19</td>\n",
       "      <td>10.55</td>\n",
       "      <td>-257.19</td>\n",
       "      <td>2.63</td>\n",
       "      <td>3.147078e+09</td>\n",
       "      <td>2.976927e+09</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>21.48</td>\n",
       "      <td>3.82</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>16 rows × 23 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    序号      代码     名称    最新价    涨跌幅   涨跌额        成交量           成交额     振幅  \\\n",
       "5    6  002031   巨轮智能   3.16  10.10  0.29  2794342.0  8.565556e+08  12.20   \n",
       "6    7  002999   天禾股份  10.08  10.04  0.92   410272.0  4.018137e+08  11.68   \n",
       "7    8  000698   沈阳化工   5.27  10.02  0.48   470033.0  2.453166e+08  10.23   \n",
       "8    9  000404   长虹华意   5.93  10.02  0.54   829143.0  4.771573e+08  10.95   \n",
       "9   10  600847   万里股份  15.40  10.00  1.40    62639.0  9.382200e+07  11.00   \n",
       "10  11  003026   中晶科技  55.99  10.00  5.09   109117.0  5.994179e+08  11.51   \n",
       "11  12  002327    富安娜   8.14  10.00  0.74   316296.0  2.505854e+08  11.08   \n",
       "12  13  002186  全 聚 德  14.74  10.00  1.34   258409.0  3.765017e+08   5.30   \n",
       "13  14  002162   悦心健康   5.39  10.00  0.49   965012.0  4.961033e+08   8.98   \n",
       "14  15  001209   洪兴股份  17.71  10.00  1.61   118622.0  2.069527e+08  10.25   \n",
       "15  16  001217    华尔泰  14.09   9.99  1.28    64808.0  8.922227e+07   9.37   \n",
       "16  17  603912    佳力图  12.44   9.99  1.13   279163.0  3.467028e+08   3.80   \n",
       "17  18  002095  生 意 宝  21.69   9.99  1.97    45486.0  9.865879e+07   0.00   \n",
       "18  19  002231   奥维通信   7.94   9.97  0.72   178932.0  1.381095e+08  10.53   \n",
       "19  20  002888   惠威科技  12.69   9.97  1.15    26920.0  3.344229e+07   9.88   \n",
       "20  21  002235   安妮股份   5.43   9.92  0.49   578241.0  3.076781e+08   5.67   \n",
       "\n",
       "       最高  ...     量比    换手率  市盈率-动态   市净率           总市值          流通市值   涨速  \\\n",
       "5    3.16  ...   3.93  14.45  721.59  2.86  6.950090e+09  6.110875e+09  0.0   \n",
       "6   10.08  ...   5.77  18.84   29.32  3.07  3.503727e+09  2.195136e+09  0.0   \n",
       "7    5.27  ...   3.52   5.98  -13.32  1.11  4.318841e+09  4.140694e+09  0.0   \n",
       "8    5.93  ...  14.69  11.92   21.37  1.19  4.127256e+09  4.125897e+09  0.0   \n",
       "9   15.40  ...   3.60   4.09  -69.32  3.41  2.360626e+09  2.360626e+09  0.0   \n",
       "10  55.99  ...   5.41  19.75  174.10  7.58  5.655991e+09  3.093854e+09  0.0   \n",
       "11   8.14  ...  14.82   6.53   15.46  1.90  6.751796e+09  3.942938e+09  0.0   \n",
       "12  14.74  ...   4.83   8.39  -19.47  5.37  4.546759e+09  4.540712e+09  0.0   \n",
       "13   5.39  ...   8.17  11.31  -43.77  4.16  4.993835e+09  4.600270e+09  0.0   \n",
       "14  17.71  ...   4.59  31.92  533.97  1.86  2.329267e+09  6.582387e+08  0.0   \n",
       "15  14.09  ...   5.02   4.53   19.41  2.30  4.676048e+09  2.017742e+09  0.0   \n",
       "16  12.44  ...  13.39   9.19  135.41  4.02  3.778563e+09  3.778563e+09  0.0   \n",
       "17  21.69  ...   1.00   1.81  238.70  5.93  5.481497e+09  5.459556e+09  0.0   \n",
       "18   7.94  ...   5.61   6.07 -466.62  6.91  2.753989e+09  2.340849e+09  0.0   \n",
       "19  12.69  ...   2.48   3.58  725.76  4.58  1.898572e+09  9.541855e+08  0.0   \n",
       "20   5.43  ...   4.19  10.55 -257.19  2.63  3.147078e+09  2.976927e+09  0.0   \n",
       "\n",
       "    5分钟涨跌  60日涨跌幅  年初至今涨跌幅  \n",
       "5     0.0   -5.95    49.06  \n",
       "6     0.0   46.94    48.89  \n",
       "7     0.0   17.90   -10.22  \n",
       "8     0.0   13.17    30.62  \n",
       "9     0.0  -17.65    -9.78  \n",
       "10    0.0   32.05   -23.77  \n",
       "11    0.0   20.41     2.52  \n",
       "12    0.0   65.62    52.12  \n",
       "13    0.0   28.03    12.76  \n",
       "14    0.0   13.02    -9.13  \n",
       "15    0.0    4.14   -26.27  \n",
       "16    0.0   21.25    20.66  \n",
       "17    0.0   77.64    31.61  \n",
       "18    0.0   -0.75    31.67  \n",
       "19    0.0    9.49    -3.13  \n",
       "20    0.0   21.48     3.82  \n",
       "\n",
       "[16 rows x 23 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "limited_up_stocks_to_watch = washed_stocks[washed_stocks['涨跌幅']>9]\n",
    "limited_up_stocks_to_watch"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "获取龙虎榜机构净买入的股票"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>收盘价</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>买方机构数</th>\n",
       "      <th>卖方机构数</th>\n",
       "      <th>机构买入总额</th>\n",
       "      <th>机构卖出总额</th>\n",
       "      <th>机构买入净额</th>\n",
       "      <th>市场总成交额</th>\n",
       "      <th>机构净买额占总成交额比</th>\n",
       "      <th>换手率</th>\n",
       "      <th>流通市值</th>\n",
       "      <th>上榜原因</th>\n",
       "      <th>上榜日期</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>600016</td>\n",
       "      <td>民生银行</td>\n",
       "      <td>10.73</td>\n",
       "      <td>10.0513</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>1.147880e+10</td>\n",
       "      <td>3.371972e+08</td>\n",
       "      <td>1.114160e+10</td>\n",
       "      <td>16825612700</td>\n",
       "      <td>66.218089</td>\n",
       "      <td>5.5761</td>\n",
       "      <td>3170.90</td>\n",
       "      <td>有价格涨跌幅限制的日收盘价格涨幅偏离值达到7%的前三只证券</td>\n",
       "      <td>2015-07-07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>601328</td>\n",
       "      <td>交通银行</td>\n",
       "      <td>6.96</td>\n",
       "      <td>2.9586</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>1.026844e+10</td>\n",
       "      <td>5.626241e+08</td>\n",
       "      <td>9.705812e+09</td>\n",
       "      <td>16011159600</td>\n",
       "      <td>60.619046</td>\n",
       "      <td>2.5315</td>\n",
       "      <td>2731.86</td>\n",
       "      <td>非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券</td>\n",
       "      <td>2015-09-02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>601939</td>\n",
       "      <td>建设银行</td>\n",
       "      <td>8.53</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>5.486709e+09</td>\n",
       "      <td>8.619264e+08</td>\n",
       "      <td>4.624782e+09</td>\n",
       "      <td>23766599100</td>\n",
       "      <td>19.459168</td>\n",
       "      <td>43.4322</td>\n",
       "      <td>537.39</td>\n",
       "      <td>无价格涨跌幅限制的证券</td>\n",
       "      <td>2007-09-25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>600048</td>\n",
       "      <td>保利发展</td>\n",
       "      <td>11.62</td>\n",
       "      <td>10.0379</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>4.304844e+09</td>\n",
       "      <td>3.631189e+08</td>\n",
       "      <td>3.941725e+09</td>\n",
       "      <td>15063098900</td>\n",
       "      <td>26.168087</td>\n",
       "      <td>6.6513</td>\n",
       "      <td>1249.76</td>\n",
       "      <td>非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券</td>\n",
       "      <td>2015-12-02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>600010</td>\n",
       "      <td>包钢股份</td>\n",
       "      <td>4.31</td>\n",
       "      <td>4.3583</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>3.248559e+09</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>3.248559e+09</td>\n",
       "      <td>5732272500</td>\n",
       "      <td>56.671404</td>\n",
       "      <td>3.6982</td>\n",
       "      <td>678.48</td>\n",
       "      <td>非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券</td>\n",
       "      <td>2015-09-02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>495</th>\n",
       "      <td>496</td>\n",
       "      <td>000823</td>\n",
       "      <td>超声电子</td>\n",
       "      <td>14.77</td>\n",
       "      <td>9.9780</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>2.912517e+08</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>2.912517e+08</td>\n",
       "      <td>1729580000</td>\n",
       "      <td>16.839449</td>\n",
       "      <td>41.3414</td>\n",
       "      <td>42.58</td>\n",
       "      <td>日换手率达到20%的前三只证券</td>\n",
       "      <td>2010-10-27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>496</th>\n",
       "      <td>497</td>\n",
       "      <td>000823</td>\n",
       "      <td>超声电子</td>\n",
       "      <td>14.77</td>\n",
       "      <td>9.9780</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>2.912517e+08</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>2.912517e+08</td>\n",
       "      <td>1729580000</td>\n",
       "      <td>16.839449</td>\n",
       "      <td>41.3414</td>\n",
       "      <td>42.58</td>\n",
       "      <td>日涨幅偏离值达到7%的前三只证券</td>\n",
       "      <td>2010-10-27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>497</th>\n",
       "      <td>498</td>\n",
       "      <td>000938</td>\n",
       "      <td>紫光股份</td>\n",
       "      <td>29.83</td>\n",
       "      <td>9.9926</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>3.129009e+08</td>\n",
       "      <td>2.170434e+07</td>\n",
       "      <td>2.911965e+08</td>\n",
       "      <td>2989953932</td>\n",
       "      <td>9.739165</td>\n",
       "      <td>3.6062</td>\n",
       "      <td>853.16</td>\n",
       "      <td>日涨幅偏离值达到7%的前5只证券</td>\n",
       "      <td>2021-08-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>498</th>\n",
       "      <td>499</td>\n",
       "      <td>600160</td>\n",
       "      <td>巨化股份</td>\n",
       "      <td>11.54</td>\n",
       "      <td>9.6958</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>2.906166e+08</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>2.906166e+08</td>\n",
       "      <td>2434386800</td>\n",
       "      <td>11.937979</td>\n",
       "      <td>4.2296</td>\n",
       "      <td>208.98</td>\n",
       "      <td>非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券</td>\n",
       "      <td>2015-07-29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>499</th>\n",
       "      <td>500</td>\n",
       "      <td>000009</td>\n",
       "      <td>中国宝安</td>\n",
       "      <td>14.12</td>\n",
       "      <td>9.9688</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>2.903348e+08</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>2.903348e+08</td>\n",
       "      <td>3321872217</td>\n",
       "      <td>8.740096</td>\n",
       "      <td>9.4082</td>\n",
       "      <td>360.26</td>\n",
       "      <td>日涨幅偏离值达到7%的前5只证券</td>\n",
       "      <td>2021-06-10</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 16 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      序号      代码    名称    收盘价      涨跌幅  买方机构数  卖方机构数        机构买入总额  \\\n",
       "0      1  600016  民生银行  10.73  10.0513      4      1  1.147880e+10   \n",
       "1      2  601328  交通银行   6.96   2.9586      4      4  1.026844e+10   \n",
       "2      3  601939  建设银行   8.53   0.0000      5      2  5.486709e+09   \n",
       "3      4  600048  保利发展  11.62  10.0379      2      2  4.304844e+09   \n",
       "4      5  600010  包钢股份   4.31   4.3583      3      0  3.248559e+09   \n",
       "..   ...     ...   ...    ...      ...    ...    ...           ...   \n",
       "495  496  000823  超声电子  14.77   9.9780      4      0  2.912517e+08   \n",
       "496  497  000823  超声电子  14.77   9.9780      4      0  2.912517e+08   \n",
       "497  498  000938  紫光股份  29.83   9.9926      3      1  3.129009e+08   \n",
       "498  499  600160  巨化股份  11.54   9.6958      2      0  2.906166e+08   \n",
       "499  500  000009  中国宝安  14.12   9.9688      3      0  2.903348e+08   \n",
       "\n",
       "           机构卖出总额        机构买入净额       市场总成交额  机构净买额占总成交额比      换手率     流通市值  \\\n",
       "0    3.371972e+08  1.114160e+10  16825612700    66.218089   5.5761  3170.90   \n",
       "1    5.626241e+08  9.705812e+09  16011159600    60.619046   2.5315  2731.86   \n",
       "2    8.619264e+08  4.624782e+09  23766599100    19.459168  43.4322   537.39   \n",
       "3    3.631189e+08  3.941725e+09  15063098900    26.168087   6.6513  1249.76   \n",
       "4    0.000000e+00  3.248559e+09   5732272500    56.671404   3.6982   678.48   \n",
       "..            ...           ...          ...          ...      ...      ...   \n",
       "495  0.000000e+00  2.912517e+08   1729580000    16.839449  41.3414    42.58   \n",
       "496  0.000000e+00  2.912517e+08   1729580000    16.839449  41.3414    42.58   \n",
       "497  2.170434e+07  2.911965e+08   2989953932     9.739165   3.6062   853.16   \n",
       "498  0.000000e+00  2.906166e+08   2434386800    11.937979   4.2296   208.98   \n",
       "499  0.000000e+00  2.903348e+08   3321872217     8.740096   9.4082   360.26   \n",
       "\n",
       "                                       上榜原因        上榜日期  \n",
       "0             有价格涨跌幅限制的日收盘价格涨幅偏离值达到7%的前三只证券  2015-07-07  \n",
       "1    非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券  2015-09-02  \n",
       "2                               无价格涨跌幅限制的证券  2007-09-25  \n",
       "3    非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券  2015-12-02  \n",
       "4    非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券  2015-09-02  \n",
       "..                                      ...         ...  \n",
       "495                         日换手率达到20%的前三只证券  2010-10-27  \n",
       "496                        日涨幅偏离值达到7%的前三只证券  2010-10-27  \n",
       "497                        日涨幅偏离值达到7%的前5只证券  2021-08-06  \n",
       "498  非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券  2015-07-29  \n",
       "499                        日涨幅偏离值达到7%的前5只证券  2021-06-10  \n",
       "\n",
       "[500 rows x 16 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_lhb_jgmmtj_em_df = ak.stock_lhb_jgmmtj_em(start_date=\"20010906\", end_date=\"20220906\")\n",
    "stock_lhb_jgmmtj_em_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "龙虎榜机构净买入的股票中剔除掉科创板、创业板、新股、st股"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>序号</th>\n",
       "      <th>代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>收盘价</th>\n",
       "      <th>涨跌幅</th>\n",
       "      <th>买方机构数</th>\n",
       "      <th>卖方机构数</th>\n",
       "      <th>机构买入总额</th>\n",
       "      <th>机构卖出总额</th>\n",
       "      <th>机构买入净额</th>\n",
       "      <th>市场总成交额</th>\n",
       "      <th>机构净买额占总成交额比</th>\n",
       "      <th>换手率</th>\n",
       "      <th>流通市值</th>\n",
       "      <th>上榜原因</th>\n",
       "      <th>上榜日期</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>600016</td>\n",
       "      <td>民生银行</td>\n",
       "      <td>10.73</td>\n",
       "      <td>10.0513</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>1.147880e+10</td>\n",
       "      <td>3.371972e+08</td>\n",
       "      <td>1.114160e+10</td>\n",
       "      <td>16825612700</td>\n",
       "      <td>66.218089</td>\n",
       "      <td>5.5761</td>\n",
       "      <td>3170.90</td>\n",
       "      <td>有价格涨跌幅限制的日收盘价格涨幅偏离值达到7%的前三只证券</td>\n",
       "      <td>2015-07-07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>601328</td>\n",
       "      <td>交通银行</td>\n",
       "      <td>6.96</td>\n",
       "      <td>2.9586</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>1.026844e+10</td>\n",
       "      <td>5.626241e+08</td>\n",
       "      <td>9.705812e+09</td>\n",
       "      <td>16011159600</td>\n",
       "      <td>60.619046</td>\n",
       "      <td>2.5315</td>\n",
       "      <td>2731.86</td>\n",
       "      <td>非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券</td>\n",
       "      <td>2015-09-02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>601939</td>\n",
       "      <td>建设银行</td>\n",
       "      <td>8.53</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>5.486709e+09</td>\n",
       "      <td>8.619264e+08</td>\n",
       "      <td>4.624782e+09</td>\n",
       "      <td>23766599100</td>\n",
       "      <td>19.459168</td>\n",
       "      <td>43.4322</td>\n",
       "      <td>537.39</td>\n",
       "      <td>无价格涨跌幅限制的证券</td>\n",
       "      <td>2007-09-25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>600048</td>\n",
       "      <td>保利发展</td>\n",
       "      <td>11.62</td>\n",
       "      <td>10.0379</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>4.304844e+09</td>\n",
       "      <td>3.631189e+08</td>\n",
       "      <td>3.941725e+09</td>\n",
       "      <td>15063098900</td>\n",
       "      <td>26.168087</td>\n",
       "      <td>6.6513</td>\n",
       "      <td>1249.76</td>\n",
       "      <td>非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券</td>\n",
       "      <td>2015-12-02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>600010</td>\n",
       "      <td>包钢股份</td>\n",
       "      <td>4.31</td>\n",
       "      <td>4.3583</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>3.248559e+09</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>3.248559e+09</td>\n",
       "      <td>5732272500</td>\n",
       "      <td>56.671404</td>\n",
       "      <td>3.6982</td>\n",
       "      <td>678.48</td>\n",
       "      <td>非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券</td>\n",
       "      <td>2015-09-02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>495</th>\n",
       "      <td>496</td>\n",
       "      <td>000823</td>\n",
       "      <td>超声电子</td>\n",
       "      <td>14.77</td>\n",
       "      <td>9.9780</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>2.912517e+08</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>2.912517e+08</td>\n",
       "      <td>1729580000</td>\n",
       "      <td>16.839449</td>\n",
       "      <td>41.3414</td>\n",
       "      <td>42.58</td>\n",
       "      <td>日换手率达到20%的前三只证券</td>\n",
       "      <td>2010-10-27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>496</th>\n",
       "      <td>497</td>\n",
       "      <td>000823</td>\n",
       "      <td>超声电子</td>\n",
       "      <td>14.77</td>\n",
       "      <td>9.9780</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>2.912517e+08</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>2.912517e+08</td>\n",
       "      <td>1729580000</td>\n",
       "      <td>16.839449</td>\n",
       "      <td>41.3414</td>\n",
       "      <td>42.58</td>\n",
       "      <td>日涨幅偏离值达到7%的前三只证券</td>\n",
       "      <td>2010-10-27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>497</th>\n",
       "      <td>498</td>\n",
       "      <td>000938</td>\n",
       "      <td>紫光股份</td>\n",
       "      <td>29.83</td>\n",
       "      <td>9.9926</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>3.129009e+08</td>\n",
       "      <td>2.170434e+07</td>\n",
       "      <td>2.911965e+08</td>\n",
       "      <td>2989953932</td>\n",
       "      <td>9.739165</td>\n",
       "      <td>3.6062</td>\n",
       "      <td>853.16</td>\n",
       "      <td>日涨幅偏离值达到7%的前5只证券</td>\n",
       "      <td>2021-08-06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>498</th>\n",
       "      <td>499</td>\n",
       "      <td>600160</td>\n",
       "      <td>巨化股份</td>\n",
       "      <td>11.54</td>\n",
       "      <td>9.6958</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>2.906166e+08</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>2.906166e+08</td>\n",
       "      <td>2434386800</td>\n",
       "      <td>11.937979</td>\n",
       "      <td>4.2296</td>\n",
       "      <td>208.98</td>\n",
       "      <td>非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券</td>\n",
       "      <td>2015-07-29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>499</th>\n",
       "      <td>500</td>\n",
       "      <td>000009</td>\n",
       "      <td>中国宝安</td>\n",
       "      <td>14.12</td>\n",
       "      <td>9.9688</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>2.903348e+08</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>2.903348e+08</td>\n",
       "      <td>3321872217</td>\n",
       "      <td>8.740096</td>\n",
       "      <td>9.4082</td>\n",
       "      <td>360.26</td>\n",
       "      <td>日涨幅偏离值达到7%的前5只证券</td>\n",
       "      <td>2021-06-10</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>429 rows × 16 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      序号      代码    名称    收盘价      涨跌幅  买方机构数  卖方机构数        机构买入总额  \\\n",
       "0      1  600016  民生银行  10.73  10.0513      4      1  1.147880e+10   \n",
       "1      2  601328  交通银行   6.96   2.9586      4      4  1.026844e+10   \n",
       "2      3  601939  建设银行   8.53   0.0000      5      2  5.486709e+09   \n",
       "3      4  600048  保利发展  11.62  10.0379      2      2  4.304844e+09   \n",
       "4      5  600010  包钢股份   4.31   4.3583      3      0  3.248559e+09   \n",
       "..   ...     ...   ...    ...      ...    ...    ...           ...   \n",
       "495  496  000823  超声电子  14.77   9.9780      4      0  2.912517e+08   \n",
       "496  497  000823  超声电子  14.77   9.9780      4      0  2.912517e+08   \n",
       "497  498  000938  紫光股份  29.83   9.9926      3      1  3.129009e+08   \n",
       "498  499  600160  巨化股份  11.54   9.6958      2      0  2.906166e+08   \n",
       "499  500  000009  中国宝安  14.12   9.9688      3      0  2.903348e+08   \n",
       "\n",
       "           机构卖出总额        机构买入净额       市场总成交额  机构净买额占总成交额比      换手率     流通市值  \\\n",
       "0    3.371972e+08  1.114160e+10  16825612700    66.218089   5.5761  3170.90   \n",
       "1    5.626241e+08  9.705812e+09  16011159600    60.619046   2.5315  2731.86   \n",
       "2    8.619264e+08  4.624782e+09  23766599100    19.459168  43.4322   537.39   \n",
       "3    3.631189e+08  3.941725e+09  15063098900    26.168087   6.6513  1249.76   \n",
       "4    0.000000e+00  3.248559e+09   5732272500    56.671404   3.6982   678.48   \n",
       "..            ...           ...          ...          ...      ...      ...   \n",
       "495  0.000000e+00  2.912517e+08   1729580000    16.839449  41.3414    42.58   \n",
       "496  0.000000e+00  2.912517e+08   1729580000    16.839449  41.3414    42.58   \n",
       "497  2.170434e+07  2.911965e+08   2989953932     9.739165   3.6062   853.16   \n",
       "498  0.000000e+00  2.906166e+08   2434386800    11.937979   4.2296   208.98   \n",
       "499  0.000000e+00  2.903348e+08   3321872217     8.740096   9.4082   360.26   \n",
       "\n",
       "                                       上榜原因        上榜日期  \n",
       "0             有价格涨跌幅限制的日收盘价格涨幅偏离值达到7%的前三只证券  2015-07-07  \n",
       "1    非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券  2015-09-02  \n",
       "2                               无价格涨跌幅限制的证券  2007-09-25  \n",
       "3    非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券  2015-12-02  \n",
       "4    非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券  2015-09-02  \n",
       "..                                      ...         ...  \n",
       "495                         日换手率达到20%的前三只证券  2010-10-27  \n",
       "496                        日涨幅偏离值达到7%的前三只证券  2010-10-27  \n",
       "497                        日涨幅偏离值达到7%的前5只证券  2021-08-06  \n",
       "498  非ST、*ST和S证券连续三个交易日内收盘价格涨幅偏离值累计达到20%的证券  2015-07-29  \n",
       "499                        日涨幅偏离值达到7%的前5只证券  2021-06-10  \n",
       "\n",
       "[429 rows x 16 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_lhb_jgmmtj_em_df = stock_lhb_jgmmtj_em_df[(stock_lhb_jgmmtj_em_df['代码'].str.startswith('00') | stock_lhb_jgmmtj_em_df['代码'].str.startswith('60')) & (~stock_lhb_jgmmtj_em_df['名称'].str.startswith('N') & ~stock_lhb_jgmmtj_em_df['名称'].str.contains('st'))]\n",
    "stock_lhb_jgmmtj_em_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "龙虎榜机构净买入的股票中涨幅大于9%同时无机构卖出的标的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_lhb_jgmmtj_em_df = stock_lhb_jgmmtj_em_df[(stock_lhb_jgmmtj_em_df['涨跌幅']>9) & (stock_lhb_jgmmtj_em_df['卖方机构数']==0)]\n",
    "pd.set_option('display.max_rows', None)  # 设置显示最大\n",
    "stock_lhb_jgmmtj_em_df = pd.DataFrame(stock_lhb_jgmmtj_em_df)\n",
    "stock_lhb_jgmmtj_em_df = stock_lhb_jgmmtj_em_df.sort_values(by=\"上榜日期\")\n",
    "stock_lhb_jgmmtj_em_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "筛选列并去除重复项"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_lhb_jgmmtj_em_df = stock_lhb_jgmmtj_em_df[['代码','上榜日期']]\n",
    "stock_lhb_jgmmtj_em_df = stock_lhb_jgmmtj_em_df.drop_duplicates(keep=False)\n",
    "stock_lhb_jgmmtj_em_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "统计上榜后的第二个交易日开盘价买入，持有20个交易日的最大跌幅和最大涨幅\n",
    "# todo 传入买入日期、买入价格、最大持仓周期"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "analysis_list = list()\n",
    "for index, row in stock_lhb_jgmmtj_em_df.iterrows():\n",
    "    # 下单日期\n",
    "    trade_date = (row['上榜日期'] + datetime.timedelta(days=1)).strftime('%Y%m%d')\n",
    "\n",
    "    # k线周期结束日期\n",
    "    now_date = datetime.datetime.now().strftime('%Y%m%d')\n",
    "\n",
    "    stock_zh_a_hist_df = ak.stock_zh_a_hist(symbol=row['代码'], period=\"daily\", start_date=trade_date, end_date=now_date, adjust=\"hfq\")\n",
    "\n",
    "    # 交易周期结束日期\n",
    "    trade_end_date = stock_zh_a_hist_df.tail(1)[\"日期\"].values[0]\n",
    "\n",
    "    # 取21个交易日的k线数据\n",
    "    stock_zh_a_hist_cut_df = stock_zh_a_hist_df.head(1 + 20)\n",
    "\n",
    "    # 取收盘价序列\n",
    "    C = stock_zh_a_hist_cut_df['收盘'].values\n",
    "\n",
    "    # 取开盘价序列\n",
    "    O = stock_zh_a_hist_cut_df['开盘'].values\n",
    "\n",
    "    # 取最高价序列\n",
    "    H = stock_zh_a_hist_cut_df['最高'].values\n",
    "\n",
    "    # 取最低价序列\n",
    "    L = stock_zh_a_hist_cut_df['最低'].values\n",
    "\n",
    "    # 取时间序列\n",
    "    DATE = stock_zh_a_hist_cut_df['日期'].values\n",
    "\n",
    "    # 信号日后的第一根k线的开盘价作为买入价格\n",
    "    buy_price = C[0]\n",
    "\n",
    "    # 取买入k线后的20根k线，作为统计k线\n",
    "    A_O = O[1:]\n",
    "    A_C = C[1:]\n",
    "    A_H = H[1:]\n",
    "    A_L = L[1:]\n",
    "    A_DATE = DATE[1:]\n",
    "\n",
    "    # 每根k线的累计涨幅\n",
    "    up_rate_acc =   np.around((A_H - buy_price)/buy_price*100, 2)\n",
    "    # 每根k线上的累计跌幅\n",
    "    down_rate_acc = np.around((A_L - buy_price)/buy_price*100,2)\n",
    "\n",
    "    # 寻找区间最高价\n",
    "    max_high = HHV(A_H,len(A_H))[-1]\n",
    "    # 寻找区间最低价\n",
    "    min_low = LLV(A_L,len(A_L))[-1]\n",
    "\n",
    "    # 最大涨幅对应的日期\n",
    "    max_high_index = np.argmax(A_H)\n",
    "    max_high_date = A_DATE[max_high_index]\n",
    "    # 最大跌幅对应的日期\n",
    "    min_low_index = np.argmin(A_L)\n",
    "    min_low_date = A_DATE[min_low_index]\n",
    "    # 是否先涨后跌\n",
    "    up_first_down_after = True if max_high_date < min_low_date else False\n",
    "\n",
    "    # 到达最大涨幅所用的天数\n",
    "\n",
    "    # 首次达到止盈对应的日期\n",
    "    first_tp_date = None\n",
    "    first_tp_up_rate = None\n",
    "\n",
    "    tp_index = np.argwhere(up_rate_acc >= 10)\n",
    "    if len(tp_index) > 0:\n",
    "        first_tp_date = A_DATE[tp_index[0][0]]\n",
    "        # 止盈的实际止盈比例\n",
    "        first_tp_up_rate = up_rate_acc[tp_index[0][0]]\n",
    "\n",
    "    # 首次达到止损对应的日期\n",
    "    first_sl_date = None\n",
    "    first_sl_down_rate = None\n",
    "\n",
    "    sl_index = np.argwhere(down_rate_acc <= -5)\n",
    "    if len(sl_index) > 0:\n",
    "        first_sl_date = A_DATE[sl_index[0][0]]\n",
    "        # 实际止损比例\n",
    "        first_sl_down_rate = down_rate_acc[sl_index[0][0]]\n",
    "\n",
    "    # 成功失败标记\n",
    "    is_success_trade = False\n",
    "    if (first_tp_date is not None and first_sl_date is None and first_tp_up_rate > 0) or (first_tp_date is not None and first_sl_date is not None and  first_tp_date < first_sl_date) or (first_sl_date is not None and first_sl_down_rate >0):\n",
    "        is_success_trade = True\n",
    "\n",
    "\n",
    "    analysis_dict = {\n",
    "        \"代码\":row['代码'],\n",
    "        \"买入日期\":trade_date,\n",
    "        #\"结束日期\":trade_end_date,\n",
    "        \"开仓价/开盘价\":buy_price,\n",
    "        \"是否是成功的交易\":is_success_trade,\n",
    "        \"是否先触及最大涨幅再触及最大跌幅\":up_first_down_after,\n",
    "        \"首次达到止盈对应的日期\":first_tp_date,\n",
    "        \"实际的止盈比例\":first_tp_up_rate,\n",
    "        \"最大涨幅\":max(up_rate_acc),\n",
    "        \"最大涨幅对应日期\": max_high_date,\n",
    "        \"首次达到止损对应的日期\":first_sl_date,\n",
    "        \"实际的止损比例\":first_sl_down_rate,\n",
    "        \"最大跌幅\":min(down_rate_acc),\n",
    "        \"最大跌幅对应的日期\":min_low_date,\n",
    "        \"最高价\":max_high,\n",
    "        \"最低价\":min_low\n",
    "    }\n",
    "\n",
    "    analysis_list.append(analysis_dict)\n",
    "\n",
    "analysis_df = pd.DataFrame(analysis_list)\n",
    "analysis_df = analysis_df.sort_values(by=\"是否是成功的交易\")\n",
    "# analysis_df.style.format(\"{:.2f}\")\n",
    "analysis_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "按股票代码分组\n",
    "查看 总交易次数、总成功次数、总失败次数、胜率"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "size = analysis_df.groupby(\"代码\").size()\n",
    "size"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在上证指数中绘制交易信号图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import akshare as ak\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Kline\n",
    "\n",
    "# k线周期结束日期\n",
    "stock_zh_index_daily_df = ak.stock_zh_index_daily(symbol=\"sh000001\")\n",
    "#print(stock_zh_index_daily_df)\n",
    "date = stock_zh_index_daily_df['date'].astype('str').values.tolist()\n",
    "data = stock_zh_index_daily_df[['open','close','low','high']].values.tolist()\n",
    "# 绘图\n",
    "c = (\n",
    "    Kline()\n",
    "    .add_xaxis(date)\n",
    "    .add_yaxis(\"kline\",\n",
    "               data,\n",
    "               itemstyle_opts=opts.ItemStyleOpts(\n",
    "                color=\"#ec0000\",\n",
    "                color0=\"#00da3c\",\n",
    "                border_color=\"#8A0000\",\n",
    "                border_color0=\"#008F28\",\n",
    "        ),\n",
    "               )\n",
    "    .set_global_opts(\n",
    "        yaxis_opts=opts.AxisOpts(is_scale=True),\n",
    "        xaxis_opts=opts.AxisOpts(is_scale=True,\n",
    "                splitarea_opts=opts.SplitAreaOpts(\n",
    "                is_show=True,\n",
    "                areastyle_opts=opts.AreaStyleOpts(opacity=1)\n",
    "            ),\n",
    "        ),\n",
    "\n",
    "        title_opts=opts.TitleOpts(title=\"Kline-基本示例\"),\n",
    "        datazoom_opts=[opts.DataZoomOpts(type_=\"inside\")],\n",
    "    )\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "统计上榜后x个交易日内回落到开盘价或者最低价时"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
